package com.nuc.list1;

import java.util.ArrayList;
import java.util.List;

/**
 * Time    : 2023/3/30 9:15
 * Author  : 王摇摆
 * FileName: List.java
 * Software: IntelliJ IDEA 2020.2.2
 * Blog    ：https://blog.csdn.net/weixin_44943389?type=blog
 */

public class Demo2 {
    public static void main(String[] args) {
        ArrayList<String> games = new ArrayList<>();
        List<String> fruits = new ArrayList<>();

        fruits.add("苹果");
        fruits.add("香蕉");
        fruits.add("桃子");
        games.add("穿越火线");
        games.add("守望先锋");
        games.add("QQ飞车");

        System.out.println("fruits中包含水果:");
        for (int i = 0; i < fruits.size(); i++) {
            System.out.print(fruits.get(i) + " ");
        }
        System.out.println();
        System.out.println("---------------");

        System.out.println("games中包含游戏：");
        games.stream().map(game -> game + " ").forEachOrdered(System.out::print);
        System.out.println();
        System.out.println("---------------");

        /**
         *    String appleString = "苹果";
         *         System.out.printf("fruits中%s苹果\n", fruits.contains(appleString) ? "包含" : "不包含");
         *
         *         if (fruits.contains(appleString))
         *             System.out.println("我喜欢吃苹果");
         *         else
         *             System.out.println("我不喜欢吃苹果");
         */

        //我来康康我喜不喜欢玩守望先锋
        String gameName = "守望先锋";
        System.out.printf("games中%s守望先锋\n", games.contains(gameName) ? "有" : "没有");

        if (games.contains(gameName))
            System.out.println("我喜欢玩守望先锋");
        else
            System.out.println("我不喜欢玩守望先锋");
        System.out.println("---------------");

    }

    public void test() {
        String name;//局部变量而已
    }
}
